import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '用户账号',
    align: "center",
    dataIndex: 'userName'
  },
  {
    title: '是否VIP',
    align: "center",
    dataIndex: 'isVip_dictText'
  },
  {
    title: '创建日期',
    align: "center",
    dataIndex: 'createTime'
  },
  {
    title: '结束日期',
    align: "center",
    dataIndex: 'endVip',
    customRender: ({ text }) => {
      text = !text ? "" : (text.length > 10 ? text.substr(0, 10) : text);
      return text;
    },
  },
  {
    title: '邀请码',
    align: "center",
    dataIndex: 'invitCode'
  },
  {
    title: '注册码',
    align: "center",
    dataIndex: 'registerCode'
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "用户账号",
    field: 'userName',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "是否VIP",
    field: 'isVip',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "is_vip_code"
    },
    //colProps: {span: 6},
  },
  {
    label: "结束日期",
    field: 'endVip',
    component: 'DatePicker',
    componentProps: {
      valueFormat: 'YYYY-MM-DD'
    },
    //colProps: {span: 6},
  },
  {
    label: "邀请码",
    field: 'invitCode',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "注册码",
    field: 'registerCode',
    component: 'Input',
    //colProps: {span: 6},
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '用户账号',
    field: 'userName',
    component: 'Input',
  },
  {
    label: '是否VIP',
    field: 'isVip',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "is_vip_code",
      type: "radio"
    },
  },
  {
    label: '创建日期',
    field: 'createTime',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
  },
  {
    label: '结束日期',
    field: 'endVip',
    component: 'DatePicker',
    componentProps: {
      valueFormat: 'YYYY-MM-DD'
    },
    dynamicDisabled: true
  },
  {
    label: '邀请码',
    field: 'invitCode',
    component: 'Input',
  },
  {
    label: '注册码',
    field: 'registerCode',
    component: 'Input',
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
];

// 高级查询数据
export const superQuerySchema = {
  userName: { title: '用户账号', order: 0, view: 'text', type: 'string', },
  isVip: { title: '是否VIP', order: 1, view: 'radio', type: 'string', dictCode: 'is_vip_code', },
  endVip: { title: '结束日期', order: 2, view: 'date', type: 'string', },
  invitCode: { title: '邀请码', order: 3, view: 'text', type: 'string', },
  registerCode: { title: '注册码', order: 4, view: 'text', type: 'string', },
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}